var Carmodl = require("../../../class/admin/carmodul.c");
module.exports = {
    prefix: "/admin/carmodul/",
    post: {
        "create": {
            des: {
                name: "createCarmodl",
                content: "添加房车型号",
                params: [
	                {
	                	key:'name',
	                	type:'string'
	                }
                ]
            },
            method: function* () {
            	var self = this;
            	try {
            		var data = yield new Carmodl(self.request.body,self.session.admin).save();
                	self.body = data;
                } catch (e) {
                    self.body = printError(e);
                };
            }
        },
        'update':{
	    	 des: {
                name: "updateCarmodl",
                content: "修改房车型号",
                params: []
    		},
            method: function* () {
            	var self = this;
            	try {
                    var receive_data = self.request.body;
	            	if(!receive_data._id){
	            		 printError('房车型号不存在！');
	            	}
	            	var data = new Carmodl(receive_data,self.session.admin).update();
                	self.body = data;
                } catch (e) {
                    self.body = printError(e);
                };
            }
    	}
    },
    delete:{
    	'delete/:_id':{
    		 des: {
                name: "postDelete",
                content: "删除指定房车型号",
                params: [
                    {
                        params: "_id",
                        type: "string"
                    }
                ]
            },
            method: function* () {
                var self = this;
                try {
                	var send_data = {_id:self.params._id};
                   	var data = yield new Carmodl(send_data,self.session.admin).delete(self.params._id);
                    self.body = data;
                } catch (e) {
                    self.body = printError(e);
                };
            }
    	}
    }
}
